 #include<stdio.h>
 #include<errno.h>
 #include<stdlib.h>
 #include<string.h>
 int main(){
     FILE* fp = fopen("log.txt","w+");
     if(!fp){
         perror("fp fopen");
         exit(-1);
     }
     for(int i = 1;i<=5;i++) {
	 	fprintf(fp,"%d:%s\n",i,"hello linux file");                                                                           
     }
	 fseek(fp,0,SEEK_SET);
	 char str[128] = {0};
	 while(fgets(str,sizeof(str)-1 ,fp)){
		str[strlen(str)- 1] = '\0';
	puts(str);
	 }
	 
     fclose(fp);
 	return 0;
}

